﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ASPNETPerformance.App_BusinessLogic.Utils.CodeProfile {
    public class AutoStopwatch : System.Diagnostics.Stopwatch, IDisposable {
        public AutoStopwatch() {
            Start();
        }

        public void Dispose() {
            Stop();
            Console.WriteLine( "当前总运行时间 : {0}", this.Elapsed );
        }
    }
}

// 调用示例
//using (new AutoStopwatchDemo())
//{
//Decimal totalObj2 = 0;
//int limitObj2 = 1000000;
//for (int i = 0; i < limit2; ++i)
//{
//totalObj2 = limitObj2  + (Decimal)Math.Sqrt(i);
//}
//}
// TimeSpan 使用示例
//Console.WriteLine(“Sum of square roots: {0}”, totalDec);
//Console.WriteLine(“Milliseconds elapsed : {0}”, timerObj.ElapsedMilliseconds);
//Console.WriteLine(“Time elapsed : {0}”, timerObj.Elapsed);